package com.zut.questionnaire.service;

import com.zut.questionnaire.pojo.Question;
import com.zut.questionnaire.pojo.Result;
import com.zut.questionnaire.repository.QuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class QuestionService {

    @Autowired
    private QuestionRepository questionRepository;

    public Result save(Question question){


        questionRepository.save(question);

        return Result.OK();
    }

    public Result update(String id,Question question){
        question.setId(id);
        questionRepository.save(question);

        return Result.OK();
    }

    public Result delete(String id){

        questionRepository.deleteById(id);

        return Result.OK();
    }

}
